package main;

import java.util.Stack;

public class MotorCautare {
/*
 * max == numarul maxim de rute*/
	protected final int MAX = 100;
	protected Ruta[] rute = new Ruta[MAX];
	protected int nrRute = 0;
	Stack btStack = new Stack();
	
	public void adaugaRuta(String p, String d, int dist, boolean rutier, boolean feroviar, boolean fluvial){
		if (nrRute < MAX){
			Ruta z = new Ruta(p, d, dist, rutier, feroviar,fluvial);
			rute[nrRute] = z;
			nrRute++;
		}
		else System.out.println("Nu mai poate fi adaugat nici o ruta");
	}
	
	public void setup() {
		adaugaRuta("Timisoara", "Biled",10, true, true, false);
		adaugaRuta("Biled", "Lovrin",7, true, true, false);
		/* ...*/
	}
	public int match (String plecare, String destinatie){
		int dist = 0;
		for (int i=0; i<nrRute; i++){
			if(rute[i].getLocalitatePlecare().equals(plecare) && rute[i].getLocalitateSosire().equals(destinatie)
					&& (rute[i].getSkip()== false)){
				dist = rute[i].getDistanta();
				rute[i].setSkip(true);
			}
		}
		return dist;
	}
	/* find = cauta toate rutele care pornesc dintr-o anumita localitate*/
	public Ruta find(String from){
		Ruta r = null;
		for (int i=0; i<nrRute; i++)
			if(rute[i].getLocalitatePlecare().equals(from) &&
					rute[i].getSkip()==false){
				r = new Ruta(from, rute[i].getLocalitateSosire(), rute[i].getDistanta());
				rute[i].setSkip(true);
			}
		return r;
	}
	
	void calculRuta(String from, String to){
		int dist;
		Ruta z;
		
		
	}
}
